package com.android.baselibrary.base

import android.os.Bundle
import android.view.View
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.launcher.ARouter

abstract class BaseDBFragment<T : ViewDataBinding>(@LayoutRes val layoutId: Int = 0) : Fragment(layoutId) {
    lateinit var mBinding: T
    private var mLayoutId = layoutId


    open fun getFragmentLayoutId():Int {
        return 0
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        if (layoutId == 0) {
            mLayoutId = getFragmentLayoutId()
        }
        mBinding =
            DataBindingUtil.bind(view)!!// DataBindingUtil.inflate(inflater, mLayoutId, container, false)
        ARouter.getInstance().inject(this)
        initView()
    }

    abstract fun initView()
}